package com.zhx.threadcoreknowledge.threadobjectclasscommonmethod;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-03 17:34
 * 用途         ： 线程sleep不释放synchromized的锁
 */
public class SleepDontReleaseMonterior implements Runnable{

    public static void main(String[] args) {
        SleepDontReleaseMonterior monterior =new SleepDontReleaseMonterior();
        new Thread(monterior).start();
        new Thread(monterior).start();

    }

    @Override
    public void run() {
        syn();
    }

    private synchronized void syn() {
        System.out.println(Thread.currentThread().getName()+"获取到了锁");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"休眠完毕");
    }
}
